package ua.javatr.android.smb;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;

import java.util.List;

public class MainActivity extends Activity {

    /**
     * Called when the activity is first created.
     *
     * @param savedInstanceState If the activity is being re-initialized after
     *                           previously being shut down then this Bundle contains the data it most
     *                           recently supplied in onSaveInstanceState(Bundle). <b>Note: Otherwise it is null.</b>
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        DBWork.initialized(getApplicationContext());

        // test fill history
        //-------------------
//        DBWork.addCard("5317","Works", "ПриватБанк");
//        DBWork.addCard("1721", "Student", "ПриватБанк");
//        DBWork.addCard("3155", "Credit", "Аваль");


        List<Card> cards = DBWork.getCardsFromDB();
        for (Card card : cards){
            Log.d("----------", "bank name = " + card.getBankName());
            Log.d("----------", "card name = " + card.getNameCard());
            Log.d("----------", "id card = " + card.getIdCard());
        }
        Log.d("----------", cards.get(0).getNameCard());
        DBWork.addToHistory(cards.get(0).getIdCard(), "balancs");
        DBWork.addToHistory(cards.get(0).getIdCard(), "balancs2");
        for (String str : DBWork.getHistory(cards.get(0).getIdCard()))
            Log.d("Hist------", "."+str+".");
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(ua.javatr.android.smb.R.menu.main, menu);
        return true;
    }

}

